function getyyData() {
    return new Promise((resolve, reject) => {
        $.ajax({
            type: "get",
            data: {},
            url: "http://localhost:8087/tbbooking/getbooking",
            dataType: "json",
            success: function (yydata) {
                console.log(yydata)
                resolve(yydata)
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                reject("查询失败");
            }
            });
    });
}

if (document.readyState !== 'loading') {
    yuyueHand();
} else {
    document.addEventListener('DOMContentLoaded', yuyueHand);
}
async function yuyueHand() {
    var table = document.getElementById("yuyue");
    var mydata = await getyyData();
    var result = '';
    console.log("yuy" + mydata)
    for (var house of mydata) {
        var myhtml = `
                <table class="grinfo">
                <tbody>           
                <tr>
                <th>中介名字：</th>
                <td>
                ${house.agentName}
                </td>
                </tr>
                
                <tr>
                <th>中介手机号：</th>
                <td>
                ${house.agentId}
                </td>
                </tr>
        
                <tr>
                <th>预约时间：</th>
                <td>
                    ${house.time}
                </td>
                </tr>
                
                <tr>
                <th>预约地址：</th>
                <td>
                ${house.address}
                </td>
                </tr>
                
                <tr>
                <th>预约状态：</th>
                <td>`
        if (house.state == 1) {
            myhtml += `申请中`
        } else if (house.state == 2) {
            myhtml += `申请通过`
        } else {
            myhtml += `申请取消`
        }
        myhtml+=`    
                </td>
                </tr>
               
                </tbody>
        </table>`;
        result += myhtml;
    }
    table.innerHTML = result;
}